import axios,{ AxiosRequestConfig,AxiosResponse } from 'axios'
import { getItem } from '@/store/store'

const instance = axios.create({
    baseURL:"http://ttapi.research.itcast.cn/"
})


instance.interceptors.request.use((config:AxiosRequestConfig) => {

    const user = getItem("user")
    if(user) {
        config.headers['Authorization'] = `Bearer ${user.token}`
    }

    return config
})

instance.interceptors.response.use((resp:AxiosResponse<any>) => {

    return resp
},err => {

    
})


export default instance